package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.system.domain.DDishes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.DPackageMapper;
import com.ruoyi.system.domain.DPackage;
import com.ruoyi.system.service.IDPackageService;

/**
 * 热卖套餐Service业务层处理
 *
 * @author tjm
 * @date 2025-04-03
 */
@Service
public class DPackageServiceImpl implements IDPackageService
{
    @Autowired
    private DPackageMapper dPackageMapper;

    /**
     * 查询热卖套餐
     *
     * @param pid 热卖套餐主键
     * @return 热卖套餐
     */
    @Override
    public DPackage selectDPackageByPid(Long pid)
    {
        return dPackageMapper.selectDPackageByPid(pid);
    }

    /**
     * 查询热卖套餐列表
     *
     * @param dPackage 热卖套餐
     * @return 热卖套餐
     */
    @Override
    public List<DPackage> selectDPackageList(DPackage dPackage)
    {
        List<DPackage> dPackages = dPackageMapper.selectDPackageList(dPackage);
        for (DPackage dPackage1 : dPackages) {
           String dishesName1 = dPackageMapper.finddish(dPackage1.getDishesID());
           dPackage1.setDishesName(dishesName1);
        }
        return dPackages;
    }

    /**
     * 新增热卖套餐
     *
     * @param dPackage 热卖套餐
     * @return 结果
     */
    @Override
    public int insertDPackage(DPackage dPackage)
    {
        return dPackageMapper.insertDPackage(dPackage);
    }

    /**
     * 修改热卖套餐
     *
     * @param dPackage 热卖套餐
     * @return 结果
     */
    @Override
    public int updateDPackage(DPackage dPackage)
    {
        return dPackageMapper.updateDPackage(dPackage);
    }

    /**
     * 批量删除热卖套餐
     *
     * @param pids 需要删除的热卖套餐主键
     * @return 结果
     */
    @Override
    public int deleteDPackageByPids(Long[] pids)
    {
        return dPackageMapper.deleteDPackageByPids(pids);
    }

    /**
     * 删除热卖套餐信息
     *
     * @param pid 热卖套餐主键
     * @return 结果
     */
    @Override
    public int deleteDPackageByPid(Long pid)
    {
        return dPackageMapper.deleteDPackageByPid(pid);
    }

    @Override
    public List<DDishes> selectName() {
        List<DDishes> dDishes = dPackageMapper.selectName();
        System.out.println(dDishes);
        return dDishes;
    }


}
